<?php



/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
 
class Gmap_Form_Admin_Level extends Authorization_Form_Admin_Level_Abstract
{
  
  public function init()
  {
    parent::init();
    
    $this
      ->setTitle('Member Level Settings')
      ->setDescription("GMAP_FORM_ADMIN_LEVEL_DESCRIPTION");
      
    $this->addElement('Radio', 'view', array(
      'label' => 'Allow Viewing of Gmaps?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_VIEW_DESCRIPTION',
      'multiOptions' => array(
        2 => 'Yes, allow viewing of all gmaps, even private ones.',
        1 => 'Yes, allow viewing of gmaps.',
        0 => 'No, do not allow gmaps to be viewed.',
      ),
      'value' => ( $this->isModerator() ? 2 : 1 ),
    ));
    if( !$this->isModerator() ) {
      unset($this->view->options[2]);
    }
    
    if( !$this->isPublic() ) 
    {
      
      $this->addElement('Radio', 'create', array(
        'label' => 'Allow Creation of Gmaps?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_CREATE_DESCRIPTION',
        'multiOptions' => array(
          1 => 'Yes, allow creation of gmaps.',
          0 => 'No, do not allow gmaps to be created.'
        ),
        'value' => 1,
      ));    
      
      $this->addElement('Radio', 'edit', array(
        'label' => 'Allow Editing of Gmaps?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_EDIT_DESCRIPTION',
        'multiOptions' => array(
          2 => 'Yes, allow members to edit all gmaps.',
          1 => 'Yes, allow members to edit their own gmaps.',
          0 => 'No, do not allow members to edit their gmaps.',
        ),
        'value' => ( $this->isModerator() ? 2 : 1 ),
      ));
      if( !$this->isModerator() ) {
        unset($this->edit->options[2]);
      }
      
      $this->addElement('Radio', 'delete', array(
        'label' => 'Allow Deletion of Gmaps?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_DELETE_DESCRIPTION',
        'multiOptions' => array(
          2 => 'Yes, allow members to delete all gmaps.',
          1 => 'Yes, allow members to delete their own gmaps.',
          0 => 'No, do not allow members to delete their gmaps.',
        ),
        'value' => ( $this->isModerator() ? 2 : 1 ),
      ));
      if( !$this->isModerator() ) {
        unset($this->delete->options[2]);
      }
  
      // Element: comment
      $this->addElement('Radio', 'comment', array(
        'label' => 'Allow Commenting on Gmaps?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_COMMENT_DESCRIPTION',
        'multiOptions' => array(
          2 => 'Yes, allow members to comment on all gmaps, including private ones.',
          1 => 'Yes, allow members to comment on gmaps.',
          0 => 'No, do not allow members to comment on gmaps.',
        ),
        'value' => ( $this->isModerator() ? 2 : 1 ),
      ));
      if( !$this->isModerator() ) {
        unset($this->comment->options[2]);
      }
      

      // Element: photo
      $this->addElement('Radio', 'photo', array(
        'label' => 'Allow Uploading of Photos?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_PHOTO_DESCRIPTION',
        'multiOptions' => array(
          2 => 'Yes, allow photo uploading to all gmaps, including private ones.',
          1 => 'Yes, allow photo uploading to gmaps.',
          0 => 'No, do not allow photo uploading.'
        ),
        'value' => ( $this->isModerator() ? 2 : 1 ),
      ));
      if( !$this->isModerator() ) {
        unset($this->photo->options[2]);
      } 
      
      
      $this->addElement('Radio', 'featured', array(
        'label' => 'Mark as Featured on Creation?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_FEATURED_DESCRIPTION',
        'multiOptions' => array(
          1 => 'Yes, mark gmap as Featured when created.',
          0 => 'No, do not mark gmap as Featured when created.'
        ),
        'value' => 0,
      ));
      
      $this->addElement('Radio', 'sponsored', array(
        'label' => 'Mark as Sponsored on Creation?',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_SPONSORED_DESCRIPTION',
        'multiOptions' => array(
          1 => 'Yes, mark gmap as Sponsored when created.',
          0 => 'No, do not mark gmap as Sponsored when created.'
        ),
        'value' => 0,
      ));
      
      // PRIVACY ELEMENTS
      $this->addElement('MultiCheckbox', 'auth_view', array(
        'label' => 'Gmaps Gmap Privacy',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_AUTHVIEW_DESCRIPTION',
          'multiOptions' => array(
            'everyone'            => 'Everyone',
            'registered'          => 'Registered Members',
            'owner_network'       => 'Friends and Networks',
            'owner_member_member' => 'Friends of Friends',
            'owner_member'        => 'Friends Only',
            'owner'               => 'Just Me'
          ),
          'value' => array('everyone', 'registered', 'owner_network','owner_member_member', 'owner_member', 'owner')
      ));
  
      $this->addElement('MultiCheckbox', 'auth_comment', array(
        'label' => 'Gmap Comment Options',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_AUTHCOMMENT_DESCRIPTION',
        'description' => '',
          'multiOptions' => array(
            'registered'          => 'Registered Members',
            'owner_network'       => 'Friends and Networks',
            'owner_member_member' => 'Friends of Friends',
            'owner_member'        => 'Friends Only',
            'owner'               => 'Just Me'
          ),
          'value' => array('registered', 'owner_network','owner_member_member', 'owner_member', 'owner')
      ));     
      

      $this->addElement('Text', 'max', array(
        'label' => 'Maximum Allowed Gmaps',
        'description' => 'GMAP_FORM_ADMIN_LEVEL_MAXNUM_DESCRIPTION',
        'class' => 'short'
      ));      
      
    } // end isPublic()
  }  
  
  public function initBAK()
  {
    $this
      ->setTitle('Member Level Settings')
      ->setDescription("GMAP_FORM_ADMIN_LEVEL_DESCRIPTION");

    $this->loadDefaultDecorators();
    $this->getDecorator('Description')->setOptions(array('tag' => 'h4', 'placement' => 'PREPEND'));

    // prepare user levels
    $table = Engine_Api::_()->getDbtable('levels', 'authorization');
    $select = $table->select();
    $user_levels = $table->fetchAll($select);
    
    foreach ($user_levels as $user_level){
      $levels_prepared[$user_level->level_id]= $user_level->getTitle();
    }
    
    // category field
    $this->addElement('Select', 'level_id', array(
      'label' => 'Member Level',
      'multiOptions' => $levels_prepared,
      'onchange' => 'javascript:fetchLevelSettings(this.value);'
    ));

    $this->addElement('Radio', 'view', array(
      'label' => 'Allow Viewing of Gmaps?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_VIEW_DESCRIPTION',
      'multiOptions' => array(
        0 => 'No, do not allow gmaps to be viewed.',
        1 => 'Yes, allow viewing of gmaps.',
        2 => 'Yes, allow viewing of all gmaps, even private ones.'
      ),
      'value' => 1,
    ));


    $this->addElement('Radio', 'create', array(
      'label' => 'Allow Creation of Gmaps?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_CREATE_DESCRIPTION',
      'multiOptions' => array(
        1 => 'Yes, allow creation of gmaps.',
        0 => 'No, do not allow gmaps to be created.'
      ),
      'value' => 1,
    ));    
    
    $this->addElement('Radio', 'edit', array(
      'label' => 'Allow Editing of Gmaps?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_EDIT_DESCRIPTION',
      'multiOptions' => array(
        0 => 'No, do not allow members to edit their gmaps.',
        1 => 'Yes, allow members to edit their own gmaps.',
        2 => 'Yes, allow members to edit all gmaps.'
      ),
      'value' => 1,
    ));

    $this->addElement('Radio', 'delete', array(
      'label' => 'Allow Deletion of Gmaps?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_DELETE_DESCRIPTION',
      'multiOptions' => array(
        0 => 'No, do not allow members to delete their gmaps.',
        1 => 'Yes, allow members to delete their own gmaps.',
        2 => 'Yes, allow members to delete all gmaps.'
      ),
      'value' => 1,
    ));


    $this->addElement('Radio', 'photo', array(
      'label' => 'Allow Uploading of Photos?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_PHOTO_DESCRIPTION',
      'multiOptions' => array(
        1 => 'Yes, allow photo uploading to gmaps.',
        0 => 'No, do not allow photo uploading.'
      ),
      'value' => 1,
    ));
    
    
    $this->addElement('Radio', 'featured', array(
      'label' => 'Mark as Featured on Creation?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_FEATURED_DESCRIPTION',
      'multiOptions' => array(
        1 => 'Yes, mark gmap as Featured when created.',
        0 => 'No, do not mark gmap as Featured when created.'
      ),
      'value' => 0,
    ));
    
    $this->addElement('Radio', 'sponsored', array(
      'label' => 'Mark as Sponsored on Creation?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_SPONSORED_DESCRIPTION',
      'multiOptions' => array(
        1 => 'Yes, mark gmap as Sponsored when created.',
        0 => 'No, do not mark gmap as Sponsored when created.'
      ),
      'value' => 0,
    ));
    
    // PRIVACY ELEMENTS
    $this->addElement('MultiCheckbox', 'auth_view', array(
      'label' => 'Gmaps Gmap Privacy',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_AUTHVIEW_DESCRIPTION',
      'multiOptions' => array(
        'everyone'       => 'Everyone',
        'owner_network' => 'Friends and Networks',
        'owner_member_member'  => 'Friends of Friends',
        'owner_member'         => 'Friends Only',
        'owner'          => 'Just Me'
      ),
      'value' => array('everyone', 'owner_network','owner_member_member', 'owner_member', 'owner')
    ));

    $this->addElement('MultiCheckbox', 'auth_comment', array(
      'label' => 'Gmap Comment Options',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_AUTHCOMMENT_DESCRIPTION',
      'description' => '',
      'multiOptions' => array(
        'everyone'       => 'Everyone',
        'owner_network' => 'Friends and Networks',
        'owner_member_member'  => 'Friends of Friends',
        'owner_member'         => 'Friends Only',
        'owner'          => 'Just Me'
      ),
      'value' => array('everyone', 'owner_network','owner_member_member', 'owner_member', 'owner')
    ));

    $this->addElement('Text', 'max', array(
      'label' => 'Maximum Allowed Gmaps',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_MAXNUM_DESCRIPTION',
      'class' => 'short'
    ));

    $this->addElement('Text', 'auth_html', array(
      'label' => 'HTML in Gmaps?',
      'description' => 'GMAP_FORM_ADMIN_LEVEL_HTML_DESCRIPTION',
      'value'=> 'strong, b, em, i, u, strike, sub, sup, p, div, pre, address, h1, h2, h3, h4, h5, h6, span, ol, li, ul, a, img, embed, br, hr'
    ));    
    
    $this->addElement('Button', 'submit', array(
      'label' => 'Save Settings',
      'type' => 'submit',
    ));

  }
}